let vm = new Vue({
    el:"#LookMain",
    data:{
        userLoginInfo:{},
        dbData:{},
    },
    methods: {
        getDetail: function (id) {
            axios({
                url: `userList/detail/${id}`,
            }).then(res => {
                let dbData = res.data.data;
                this.dbData = dbData;
            })
        },
        saveDetail: function () {
            console.log(this.dbData);
            axios({
                url: `userList/saveDetail/${this.userLoginInfo.data.id}`,
                method: 'post',
                data: this.dbData,
                contentType: 'application/json'
            }).then(res => {
                alert(res.data.message);
            })
        },
        getUploadFile: function (event) {

            let formData = new FormData();
            // 该file属性名 须和后台MultipartFile参数名 一致
            formData.append("file",event.currentTarget.files[0]);
            axios({
                url: `userList/uploadPic`,
                method: 'post',
                headers:{
                    "content-type":"multipart/form-data"
                },
                data:formData
            }).then(res=>{
                //返回的图片路径  我们更新前端
                let fileName = res.data.data;
                this.dbData.pic=fileName;
                $("#pic").attr("src","/upload/"+fileName);
                $("#sidebarPic").attr("src","/upload/"+fileName)
            }).catch(error=>{
                alert("异常")
            })
        },
        selectChange:function (event) {
            this.dbData.name=event.currentTarget.value;
        },
        bandPlaceholder:function () {
            this.dbData.age=$("#ageInput")[0].value
        },
        inputRadio:function (event) {
            this.dbData.gender=event.target.value
        },
        checkboxCustom1:function (event) {
            if (event.target.checked) {
                this.dbData.is_secret=1
            }
            else {
                vm.dbData.is_secret=0
            }

        }
    },
    created:function () {
        let userInfo = sessionStorage.getItem("vmUserInfo");
        if (userInfo != null) {
            this.userLoginInfo = JSON.parse(userInfo);
            this.getDetail(this.userLoginInfo.data.id);
            // this.getDeptList();
        } else {
            location.href = "";
        }
    },
});